package top.soft.util;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName: Request
 * @Author: Amosen
 * @Since: 2021/4/21
 */
public class Request {

	private String url;

	private String method;

	private Map<String, String> data;

	public static final String GET = "GET";

	public static final String POST = "POST";

	public static final String DELETE = "DELETE";

	public static final String PUT = "PUT";

	public Request() {
		this.method = GET;
		this.data = new HashMap<String, String>();
	}

	public Request(String url, String method, Map<String, String> data) {
		this.url = url;
		this.method = method;
		this.data = data;
	}

	public Request(String url, String method) {
		this.url = url;
		this.method = method;
		this.data = new HashMap<>();
	}

	public Request(String url) {
		this.url = url;
		this.method = GET;
		this.data = new HashMap<>();
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getMethod() {
		return method;
	}

	public void setMethod(String method) {
		this.method = method;
	}

	public Map<String, String> getData() {
		return data;
	}

	public void setData(Map<String, String> data) {
		this.data = data;
	}

	public Request addData(String key, String value) {
		this.data.put(key, value);
		return this;
	}

	@Override
	public String toString() {
		return "Request{" + "url='" + url + '\'' + ", method='" + method + '\'' + ", data=" + data + '}';
	}
}
